package com.ocom.webapi.controller;

import com.alibaba.fastjson.JSONObject;
import com.ocom.common.constant.WebApiServiceUrl;
import com.ocom.common.request.payconfig.xfwalletinfo.GetConsAllWalletRequest;
import com.ocom.common.request.payconfig.xfwalletinfo.GetConsWalletListRequest;
import com.ocom.common.request.payconfig.xfwalletinfo.SetConsAllWalletRequest;
import com.ocom.common.resp.Result;
import com.ocom.common.vo.payconfig.SubAccountVo;
import com.ocom.security.authentication.YoCiUser;
import com.ocom.security.utils.SecurityUtils;
import com.ocom.webapi.feign.PayConfigClientService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Description: 德生科技
 **/
@RestController
@PreAuthorize("@pms.hasRole('ROLE_WEB')" )
public class TecSunController {

    @Autowired
    private PayConfigClientService payConfigClientService;

    @PostMapping(WebApiServiceUrl.Url_ConsWalletInfo)
    public Result consWalletInfo(@RequestBody GetConsAllWalletRequest request) {
        return payConfigClientService.getConsAllWallet(request);
    }

    @PostMapping(WebApiServiceUrl.Url_ConsWalletList)
    public Result consWalletList(@RequestBody GetConsWalletListRequest request) {
        return payConfigClientService.getConsWalletList(request);
    }

    @PostMapping(WebApiServiceUrl.Url_ConsWalletSet)
    public Result consWalletSet(@RequestBody SetConsAllWalletRequest request) {
        return payConfigClientService.setConsWallet(request);
    }

    @PostMapping(WebApiServiceUrl.Url_SubAccountList)
    public Result subAccountList(@RequestBody JSONObject jsonObject) {
        YoCiUser yoCiUser= SecurityUtils.getYoCiUser();
        Long comId = yoCiUser.getComId();
      return  payConfigClientService.getSubAccountList(comId);
    }

    @PostMapping(WebApiServiceUrl.Url_SubAccountSet)
    public Result subAccountSet(@RequestBody SubAccountVo request) {
        YoCiUser yoCiUser= SecurityUtils.getYoCiUser();
        Long comId = yoCiUser.getComId();
        request.setComId(comId);
        return payConfigClientService.setSubAccount(request);
    }
}
